/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.sql.Timestamp;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;

/**
 *
 * @author Ee Ting
 */
@Entity
public class MPSMonthlyRecord implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long mpsMonthlyId;
    
    private int month;
    private int year;
    private ProdRecordMPS mpsYearly;
    private ProdRecordMPS mpsMonthly;
    private int workingDaysYearly;
    private int workingDaysMonthly;
    @OneToOne(cascade = {CascadeType.PERSIST})
    private SystemUser createdBy;
    private Timestamp createdDate;
    
    @OneToOne(cascade={CascadeType.PERSIST})
    private SOPRecord sopr;
    
    public void create(int mth, int yr, ProdRecordMPS mpsY, ProdRecordMPS mpsM, int wDaysY, int wDaysM, SystemUser user)
    {
        this.setMonth(mth);
        this.setYear(yr);
        this.setMpsMonthly(mpsM);
        this.setMpsYearly(mpsY);
        this.setWorkingDaysMonthly(wDaysM);
        this.setWorkingDaysYearly(wDaysY);
        this.setCreatedBy(user);
        java.util.Date tmp = new java.util.Date();
        this.setCreatedDate(new Timestamp(tmp.getTime()));
    }

    public SOPRecord getSopr() {
        return sopr;
    }

    public void setSopr(SOPRecord sopr) {
        this.sopr = sopr;
    }

    public SystemUser getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(SystemUser createdBy) {
        this.createdBy = createdBy;
    }

    public Timestamp getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Timestamp createdDate) {
        this.createdDate = createdDate;
    }

    public int getMonth() {
        return month;
    }

    public void setMonth(int month) {
        this.month = month;
    }

    public Long getMpsMonthlyId() {
        return mpsMonthlyId;
    }

    public void setMpsMonthlyId(Long mpsId) {
        this.mpsMonthlyId = mpsId;
    }

    public ProdRecordMPS getMpsMonthly() {
        return mpsMonthly;
    }

    public void setMpsMonthly(ProdRecordMPS mpsMonthly) {
        this.mpsMonthly = mpsMonthly;
    }

    public ProdRecordMPS getMpsYearly() {
        return mpsYearly;
    }

    public void setMpsYearly(ProdRecordMPS mpsYearly) {
        this.mpsYearly = mpsYearly;
    }

    public int getWorkingDaysMonthly() {
        return workingDaysMonthly;
    }

    public void setWorkingDaysMonthly(int workingDaysMonthly) {
        this.workingDaysMonthly = workingDaysMonthly;
    }

    public int getWorkingDaysYearly() {
        return workingDaysYearly;
    }

    public void setWorkingDaysYearly(int workingDaysYearly) {
        this.workingDaysYearly = workingDaysYearly;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (mpsMonthlyId != null ? mpsMonthlyId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MPSMonthlyRecord)) {
            return false;
        }
        MPSMonthlyRecord other = (MPSMonthlyRecord) object;
        if ((this.mpsMonthlyId == null && other.mpsMonthlyId != null) || (this.mpsMonthlyId != null && !this.mpsMonthlyId.equals(other.mpsMonthlyId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.MPSRecord[ id=" + mpsMonthlyId + " ]";
    }
    
}
